package com.lanmao.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lanmao.blog.entity.Links;
import com.lanmao.blog.mapper.LinksMapper;
import com.lanmao.blog.service.LinksService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lanmao
 * @since 2022-03-13
 */
@Service
public class LinksServiceImpl extends ServiceImpl<LinksMapper, Links> implements LinksService {

    @Override
    public Page<Links> pageLinks(Long current, Long size) {

        Page<Links> linksPage = new Page<>(current,size);
        //构建条件
        QueryWrapper<Links> wrapper = new QueryWrapper<>();
        //以创建时间排序（降序）
        wrapper.orderByDesc("create_time");
        //调用mybatis plus分页方法进行查询
        baseMapper.selectPage(linksPage,wrapper);
        return linksPage;
    }
}
